package com.future.account.client.hystrix;

import com.alibaba.fastjson.JSONObject;
import com.future.account.client.EmailClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * 邮件发送客户端容错策略
 *
 * @author shiyong
 * 2022/2/19 18:11
 */
@Component
@Slf4j
public class EmailClientFallback implements EmailClient {

    /**
     * 发送邮件
     *
     * @param email   邮件地址
     * @param content 邮件内容
     * @return com.alibaba.fastjson.JSONObject
     * @author shiyong
     * 2022/2/19 19:21
     */
    @Override
    public JSONObject sendEmail(String email, String content) {
        log.error("调用邮件发送接口失败，触发容错策略");

        JSONObject result = new JSONObject();
        result.put("msg", "向" + email + "发送邮件失败");
        return result;
    }
}
